import logging

logging.basicConfig(filename='dev.log',
                    level=logging.DEBUG,
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s >>> %(message)s',
                    datefmt='%b%d %Y %H:%M:%S',
                    filemode='w')
mlog = logging

from flask import Flask

# init app
app = Flask(__name__)
app.config.from_pyfile('config.py')

# init database
from flask.ext.sqlalchemy import SQLAlchemy

db = SQLAlchemy(app)

# init login manager
from flask.ext.login import LoginManager

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'login'

# init api services
from .api import *
from flask.ext.restful import Api

api = Api(app)
api.add_resource(HelloWorld, '/api/test', endpoint='test')
api.add_resource(GetUser, '/api/get_user/<user_id>', endpoint='user')

# init email services
from flask_mail import Mail

mail = Mail(app)

from app import views, models, api
